﻿using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

namespace KC.DataAccess.Admin.Migrations
{
    public partial class addTenantSetting : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropColumn(
                name: "EnableCallCenter",
                schema: "cDba",
                table: "tenant_TenantUser");

            migrationBuilder.DropColumn(
                name: "EnableEmail",
                schema: "cDba",
                table: "tenant_TenantUser");

            migrationBuilder.DropColumn(
                name: "EnableId5",
                schema: "cDba",
                table: "tenant_TenantUser");

            migrationBuilder.DropColumn(
                name: "EnableLogistics",
                schema: "cDba",
                table: "tenant_TenantUser");

            migrationBuilder.DropColumn(
                name: "EnablePayment",
                schema: "cDba",
                table: "tenant_TenantUser");

            migrationBuilder.DropColumn(
                name: "EnableSms",
                schema: "cDba",
                table: "tenant_TenantUser");

            migrationBuilder.DropColumn(
                name: "EnableWeixin",
                schema: "cDba",
                table: "tenant_TenantUser");

            migrationBuilder.DropColumn(
                name: "OwnDomainLevel",
                schema: "cDba",
                table: "tenant_TenantUser");

            migrationBuilder.DropColumn(
                name: "OwnDomainName",
                schema: "cDba",
                table: "tenant_TenantUser");

            migrationBuilder.CreateTable(
                name: "tenant_TenantUserSetting",
                schema: "cDba",
                columns: table => new
                {
                    PropertyAttributeId = table.Column<int>(nullable: false)
                        .Annotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn),
                    DataType = table.Column<int>(nullable: false),
                    Name = table.Column<string>(maxLength: 256, nullable: true),
                    Value = table.Column<string>(nullable: true),
                    Value1 = table.Column<string>(nullable: true),
                    Value2 = table.Column<string>(nullable: true),
                    CanEdit = table.Column<bool>(nullable: false),
                    IsProviderAttr = table.Column<bool>(nullable: false),
                    Index = table.Column<int>(nullable: false),
                    TenantId = table.Column<int>(nullable: false),
                    IsDeleted = table.Column<bool>(nullable: false),
                    CreatedBy = table.Column<string>(nullable: true),
                    CreatedDate = table.Column<DateTime>(nullable: false),
                    ModifiedBy = table.Column<string>(nullable: true),
                    ModifiedDate = table.Column<DateTime>(nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_tenant_TenantUserSetting", x => x.PropertyAttributeId);
                    table.ForeignKey(
                        name: "FK_tenant_TenantUserSetting_tenant_TenantUser_TenantId",
                        column: x => x.TenantId,
                        principalSchema: "cDba",
                        principalTable: "tenant_TenantUser",
                        principalColumn: "TenantId",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_tenant_TenantUserSetting_TenantId",
                schema: "cDba",
                table: "tenant_TenantUserSetting",
                column: "TenantId");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "tenant_TenantUserSetting",
                schema: "cDba");

            migrationBuilder.AddColumn<bool>(
                name: "EnableCallCenter",
                schema: "cDba",
                table: "tenant_TenantUser",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn<bool>(
                name: "EnableEmail",
                schema: "cDba",
                table: "tenant_TenantUser",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn<bool>(
                name: "EnableId5",
                schema: "cDba",
                table: "tenant_TenantUser",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn<bool>(
                name: "EnableLogistics",
                schema: "cDba",
                table: "tenant_TenantUser",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn<bool>(
                name: "EnablePayment",
                schema: "cDba",
                table: "tenant_TenantUser",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn<bool>(
                name: "EnableSms",
                schema: "cDba",
                table: "tenant_TenantUser",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn<bool>(
                name: "EnableWeixin",
                schema: "cDba",
                table: "tenant_TenantUser",
                nullable: false,
                defaultValue: false);

            migrationBuilder.AddColumn<int>(
                name: "OwnDomainLevel",
                schema: "cDba",
                table: "tenant_TenantUser",
                nullable: false,
                defaultValue: 0);

            migrationBuilder.AddColumn<string>(
                name: "OwnDomainName",
                schema: "cDba",
                table: "tenant_TenantUser",
                nullable: true);
        }
    }
}
